package app.common.utils.cjt.ao;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;

/**
 * 进货单创建
 * @author feizns
 * @since 2023/3/31
 */
@NoArgsConstructor
@Data
public class PurchaseArrivalCreateAo {

    /**
     * dto
     */
    private Dto dto;

    /**
     * Dto
     */
    @NoArgsConstructor
    @Data
    public static class Dto {
        /**
         * code
         */
        private String code;
        /**
         * voucherDate
         */
        private String voucherDate;
        /**
         * invoiceType
         */
        private InvoiceType invoiceType;
        /**
         * externalCode
         */
        private String externalCode;
        /**
         * businessType
         */
        private BusinessType businessType;
        /**
         * partner
         */
        private Partner partner;
        /**
         * warehouse
         */
        private Warehouse warehouse;
        /**
         * memo
         */
        private String memo;
        /**
         * voucherDetails
         */
        private VoucherDetails voucherDetailsObj;

        private List<VoucherDetails> voucherDetails;

        public List<VoucherDetails> getVoucherDetails() {
            return CollectionUtils.isEmpty(voucherDetails) ? Collections.singletonList(voucherDetailsObj) : voucherDetails;
        }
        /**
         * arrivalMultiSettleDetails
         */
        private ArrivalMultiSettleDetails arrivalMultiSettleDetailsObj;

        public ArrivalMultiSettleDetails getArrivalMultiSettleDetails() {
            return arrivalMultiSettleDetailsObj;
        }

        /**
         * InvoiceType
         */
        @NoArgsConstructor
        @Data
        public static class InvoiceType {
            /**
             * code
             */
            private String code;
        }

        /**
         * BusinessType
         */
        @NoArgsConstructor
        @Data
        @AllArgsConstructor
        public static class BusinessType {
            /**
             * code
             */
            private String code;
        }

        /**
         * Partner
         */
        @NoArgsConstructor
        @Data
        @AllArgsConstructor
        public static class Partner {
            /**
             * code
             */
            private String code;
        }

        /**
         * Warehouse
         */
        @NoArgsConstructor
        @Data
        @AllArgsConstructor
        public static class Warehouse {
            /**
             * code
             */
            private String code;
        }

        /**
         * VoucherDetails
         */
        @NoArgsConstructor
        @Data
        public static class VoucherDetails {
            /**
             * inventory
             */
            private Inventory inventory;
            /**
             * unit
             */
            private Unit unit;
            /**
             * quantity
             */
            private Double quantity;
            /**
             * origTaxAmount
             */
            private BigDecimal origTaxAmount;

            /**
             * 源自折扣金额
             */
            private BigDecimal origDiscountAmount;

            /**
             * Inventory
             */
            @NoArgsConstructor
            @Data
            @AllArgsConstructor
            public static class Inventory {
                /**
                 * code
                 */
                private String code;
            }

            /**
             * Unit
             */
            @NoArgsConstructor
            @Data
            public static class Unit {
                /**
                 * name
                 */
                private String name;
            }
        }

        /**
         * ArrivalMultiSettleDetails
         */
        @NoArgsConstructor
        @Data
        public static class ArrivalMultiSettleDetails {
            /**
             * code
             */
            private String code;
            /**
             * settleStyle
             */
            private SettleStyle settleStyle;
            /**
             * bankAccount
             */
            private BankAccount bankAccount;
            /**
             * origAmount
             */
            private Integer origAmount;
            /**
             * documentCode
             */
            private String documentCode;

            /**
             * SettleStyle
             */
            @NoArgsConstructor
            @Data
            public static class SettleStyle {
                /**
                 * code
                 */
                private String code;
            }

            /**
             * BankAccount
             */
            @NoArgsConstructor
            @Data
            public static class BankAccount {
                /**
                 * name
                 */
                private String name;
            }
        }
    }

}
